package com.gper.edu.implicts

/**
 * @Author: ellis.guan
 * @Description:
 * @Date: 2020/4/5 16:36
 * @Version: 1.0
 */
object ImplicitClassDemo {

  /**
   * 底层生成：ImplicitClassDemo$ImplicitDB
   * @param mysql
   */
  implicit class ImplicitDB(val mysql: Mysql){
    def delete(id:Int): Unit ={
      println("extend class function by implicit class. delete id = "+id+" data.")
    }
  }

  def main(args: Array[String]): Unit = {
    val mysql = new Mysql
    mysql.insert(55)

    /**
     * 底层关联：ImplicitDB(mysql).delete(12)
     */
    mysql.delete(12)
  }
}
